package com.starsoft.trade.util;

import com.starsoft.smdc.util.SecurityType;
import com.starsoft.trade.bean.TradeBill;

public enum TradeType {

	stockdiv, funddiv, bonddiv,
	stockbuy, stocksell, 
	transfer, oci,
	fundbuy, fundsell, 
	indexbuy, indexsell,
	bondbuy, bondsell;

	public static TradeType get(TradeBill bill) {
		String tradeType = bill.getBillType();
		return TradeType.valueOf(tradeType);
	}

	public boolean isSell() {
		return stocksell == this || fundsell == this || indexsell == this || bondsell == this;
	}

	public boolean isBuy() {
		return stockbuy == this || fundbuy == this || indexbuy == this || bondbuy == this;
	}

	public boolean isSellBuy() {
		return isSell() || isBuy();
	}

	public boolean isDiv() {
		if (stockdiv == this || funddiv == this) {
			return true;
		}
		if (bonddiv == this) {
			return true;
		}
		return false;
	}
	
	public SecurityType getSecType(){
		if (stockbuy == this || stocksell == this || stockdiv == this) {
			return SecurityType.stock;
		}
		if (fundbuy == this || fundsell == this || funddiv == this) {
			return SecurityType.fund;
		}
		if(indexbuy == this || indexsell == this){
			return SecurityType.index;
		}
		if (bondbuy == this || bondsell == this || bonddiv == this) {
			return SecurityType.bond;
		}
		return null;
	}
}
